home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / bipl.zip / PROCS.ZIP / FILEDIM.ICN < prev    next >
Text File  |  1992-09-28  |  947b  |  42 lines

  1. ############################################################################
  2. #
  3. #    File:     filedim.icn
  4. #
  5. #    Subject:  Procedure to compute file dimensions
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     August 1, 1992
  10. #
  11. ###########################################################################
  12. #
  13. #  filedim(s, p) computes the number of rows and maximum column width
  14. #  of the file named s.  The procedure p, which defaults to detab, i
  15. #  applied to each line.  For example, to have lines left as is, use
  16. #
  17. #    filedim(s, 1)
  18. #
  19. ############################################################################
  20.  
  21. record textdim(cols, rows)
  22.  
  23. procedure filedim(s, p)
  24.    local input, rows, cols
  25.  
  26.    /p := detab
  27.  
  28.    input := open(s) | stop("*** cannot open ", s)
  29.  
  30.    rows := cols := 0
  31.  
  32.    while line := p(read(input)) do {
  33.       rows +:= 1
  34.       cols <:= *line
  35.       }
  36.  
  37.    close(input)
  38.  
  39.    return textdim(cols, rows)
  40.  
  41. end
  42.